/**
 * 文章相关模块
 */
import request from '@/utils/request'
// export interface ArticleParams {
// }

// 单个文章详情
export interface ArticleDetail {
  slug: string
  title: string
  description: string
  body: string
  tagList: string[]
  createdAt?: string
  updatedAt: string
  favorited: boolean
  favoritesCount: number
  author: {
    username: string
    bio: string
    image: string
    following: boolean
  }
}

// 文章列表
export interface ArticleListData {
  articlesCount: number,
  // articles: ArticleDetail[]
  articles: Array<ArticleDetail>[]
}

// get public articles
export const getArticles = async (): Promise<ArticleListData> => {
  const res = await request({
    method: 'GET',
    url: '/api/articles'
  })
  console.info(res.data)
  return res.data // 声明返回值的类型
}
